import 'package:flutter/material.dart';
import 'app_state_service.dart';

class AppStateProvider extends InheritedWidget {
  final AppStateService appState;

  const AppStateProvider({
    super.key,
    required this.appState,
    required super.child,
  });

  static AppStateService of(BuildContext context) {
    final provider = context.dependOnInheritedWidgetOfExactType<AppStateProvider>();
    assert(provider != null, 'No AppStateProvider found in context');
    return provider!.appState;
  }

  @override
  bool updateShouldNotify(AppStateProvider oldWidget) {
    return appState != oldWidget.appState;
  }
}